package main

import (
	"encoding/json"
	"fmt"
)

type InventoryDO struct {
	Goods   int64 `gorm:"type:int;index" json:"1"` // 商品id
	Stocks  int32 `gorm:"type:int"`                // 库存数量
	Version int32 `gorm:"type:int"`                // 乐观锁
}

func main() {
	m := make(map[string]any, 2)
	fmt.Println(len(m))
	m["1"] = 30
	m["stocks"] = 40

	marshal, _ := json.Marshal(m)

	var inv InventoryDO

	json.Unmarshal(marshal, &inv)
	fmt.Println(inv)
}
